+++ /dev/null
-[submodule "libs/hammer.rs"]
- path = libs/hammer.rs
- url = https://github.com/wycats/hammer.rs.git
-[submodule "libs/hamcrest-rust"]
- path = libs/hamcrest-rust
- url = https://github.com/carllerche/hamcrest-rust/
-[submodule "libs/toml-rs"]
- path = libs/toml-rs
- url = https://github.com/alexcrichton/toml-rs
--- /dev/null
+[project]
+
+name = "cargo"
+version = "0.0.1-pre"
+authors = ["Yehuda Katz <wycats@gmail.com>",
+ "Carl Lerche <me@carllerche.com>"]
+
+[[lib]]
+
+name = "cargo"
+path = "src/cargo/lib.rs"
+
+# TODO: remove all these `rev` markers once we have an official lockfile
+[dependencies.hammer]
+git = "https://github.com/wycats/hammer.rs"
+rev = "c085c639"
+
+[dependencies.toml]
+git = "https://github.com/alexcrichton/toml-rs"
+rev = "a3c7f2c3"
+
+[dependencies.hamcrest]
+git = "https://github.com/carllerche/hamcrest-rust.git"
+rev = "05acf768"
+
+[[bin]]
+name = "cargo"
+test = false
+
+[[bin]]
+name = "cargo-build"
+test = false
+
+[[bin]]
+name = "cargo-clean"
+test = false
+
+[[bin]]
+name = "cargo-git-checkout"
+test = false
+
+[[bin]]
+name = "cargo-read-manifest"
+test = false
+
+[[bin]]
+name = "cargo-run"
+test = false
+
+[[bin]]
+name = "cargo-rustc"
+test = false
+
+[[bin]]
+name = "cargo-test"
+test = false
+
+[[bin]]
+name = "cargo-verify-project"
+test = false
+
+[[bin]]
+name = "cargo-version"
+test = false
+
+[[bin]]
+name = "cargo-new"
+test = false
+
+[[test]]
+name = "tests"
-RUSTC_FLAGS ?=
DESTDIR ?=
PREFIX ?= /usr/local
-TARGET ?= target
PKG_NAME ?= cargo-nightly
ifeq ($(wildcard rustc/bin),)
export PATH := $(CURDIR)/rustc/bin:$(PATH)
-# Link flags to pull in dependencies
-BINS = cargo \
- cargo-build \
- cargo-clean \
- cargo-read-manifest \
- cargo-rustc \
- cargo-verify-project \
- cargo-git-checkout \
- cargo-test \
- cargo-run \
- cargo-version \
- cargo-new
-
-SRC = $(shell find src -name '*.rs' -not -path 'src/bin*')
-
ifeq ($(OS),Windows_NT)
X = .exe
endif
-DEPS = -L libs/hammer.rs/target -L libs/toml-rs/build
-TOML = libs/toml-rs/build/$(shell $(RUSTC) --print-file-name libs/toml-rs/src/toml.rs)
-HAMMER = libs/hammer.rs/target/$(shell $(RUSTC) --crate-type=lib --print-file-name libs/hammer.rs/src/hammer.rs)
-HAMCREST = libs/hamcrest-rust/target/libhamcrest.timestamp
-LIBCARGO = $(TARGET)/libcargo.rlib
-TESTDIR = $(TARGET)/tests
+TARGET = target
DISTDIR = $(TARGET)/dist
PKGDIR = $(DISTDIR)/$(PKG_NAME)
-BIN_TARGETS = $(BINS:%=$(TARGET)/%$(X))
-
-all: $(BIN_TARGETS)
-
-# === Dependencies
-
-$(HAMMER): $(wildcard libs/hammer.rs/src/*.rs)
- $(MAKE) -C libs/hammer.rs
-
-$(TOML): $(wildcard libs/toml-rs/src/*.rs)
- $(MAKE) -C libs/toml-rs
-
-$(HAMCREST): $(shell find libs/hamcrest-rust/src/hamcrest -name '*.rs')
- $(MAKE) -C libs/hamcrest-rust
-
-$(TARGET)/:
- mkdir -p $@
-
-$(TESTDIR)/:
- mkdir -p $@
-# === Cargo
+BIN_TARGETS := $(wildcard src/bin/*.rs)
+BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%)
+BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS))
+BIN_TARGETS := $(BIN_TARGETS:%=$(TARGET)/%$(X))
-$(LIBCARGO): $(SRC) $(HAMMER) $(TOML) | $(TARGET)/
- $(RUSTC) $(RUSTC_FLAGS) $(DEPS) --out-dir $(TARGET) src/cargo/lib.rs
+CARGO := $(TARGET)/snapshot/cargo-nightly/bin/cargo$(X)
-libcargo: $(LIBCARGO)
+all: $(CARGO)
+ $(CARGO) build $(ARGS)
-# === Commands
+$(CARGO): src/snapshots.txt
+ python src/etc/dl-snapshot.py
+ touch $@
-$(BIN_TARGETS): $(TARGET)/%$(X): src/bin/%.rs $(HAMMER) $(TOML) $(LIBCARGO)
- $(RUSTC) $(RUSTC_FLAGS) $(DEPS) -L$(TARGET) --out-dir $(TARGET) $<
# === Tests
-TEST_SRC = $(shell find tests -name '*.rs')
-TEST_DEPS = $(DEPS) -L libs/hamcrest-rust/target
+test: test-unit style no-exes
-$(TESTDIR)/test-integration: $(HAMCREST) $(TEST_SRC) $(BIN_TARGETS) | $(TESTDIR)/
- $(RUSTC) --test $(TEST_DEPS) -L$(TARGET) -o $@ tests/tests.rs
-
-$(TESTDIR)/test-unit: $(TOML) $(HAMCREST) $(SRC) $(HAMMER) | $(TESTDIR)/
- $(RUSTC) --test -g $(RUSTC_FLAGS) $(TEST_DEPS) -o $@ src/cargo/lib.rs
-
-test-unit: $(TESTDIR)/test-unit
- $< $(only)
-
-test-integration: $(TESTDIR)/test-integration
- $< $(only)
-
-test: test-unit test-integration style no-exes
+test-unit: $(CARGO)
+ $(CARGO) test $(only)
style:
sh tests/check-style.sh
no-exes:
- find $$(git ls-files | grep -v '^lib') -perm +111 -type f \
+ find $$(git ls-files) -perm +111 -type f \
-not -name '*.sh' -not -name '*.rs' | grep '.*' \
&& exit 1 || exit 0
-clean:
- rm -rf $(TARGET)
+# === Misc
clean-all: clean
- git submodule foreach make clean
+clean:
+ rm -rf $(TARGET)
dist: $(DISTDIR)/$(PKG_NAME).tar.gz
$(DISTDIR)/$(PKG_NAME).tar.gz: $(PKGDIR)/lib/cargo/manifest.in
tar -czvf $@ -C $(DISTDIR) $(PKG_NAME)
-$(PKGDIR)/lib/cargo/manifest.in: $(BIN_TARGETS) Makefile
+$(PKGDIR)/lib/cargo/manifest.in: all
rm -rf $(PKGDIR)
mkdir -p $(PKGDIR)/bin $(PKGDIR)/lib/cargo
cp $(TARGET)/cargo$(X) $(PKGDIR)/bin
cp $(BIN_TARGETS) $(PKGDIR)/lib/cargo
- rm $(PKGDIR)/lib/cargo/cargo$(X)
(cd $(PKGDIR) && find . -type f | sed 's/^\.\///') \
> $(DISTDIR)/manifest-$(PKG_NAME).in
- cp src/install.sh $(PKGDIR)
+ cp src/etc/install.sh $(PKGDIR)
cp README.md LICENSE-MIT LICENSE-APACHE $(PKGDIR)
cp LICENSE-MIT $(PKGDIR)
mv $(DISTDIR)/manifest-$(PKG_NAME).in $(PKGDIR)/lib/cargo/manifest.in
$(PKGDIR)/install.sh --prefix=$(PREFIX) --destdir=$(DESTDIR)
# Setup phony tasks
-.PHONY: all clean distclean test test-unit test-integration libcargo style
+.PHONY: all clean test test-unit style
# Disable unnecessary built-in rules
.SUFFIXES:
+++ /dev/null
-Subproject commit 05acf7681ab28198e5d7c1cc9561195de02d8d2a
+++ /dev/null
-Subproject commit c085c639ac06909301707721b174e83f40bbac70
+++ /dev/null
-Subproject commit a3c7f2c38ef795ad34e225ca54fa6bf625e8a842
-#![crate_name = "cargo-run"]
#![feature(phase)]
#[phase(plugin, link)]
fn process(args: Vec<String>) -> (String, Vec<String>) {
let mut args = Vec::from_slice(args.tail());
- let head = args.shift().unwrap_or("--help".to_string());
+ let head = args.remove(0).unwrap_or("--help".to_string());
(head, args)
}
--- /dev/null
+import distutils.spawn
+import hashlib
+import os
+import subprocess
+import sys
+import tarfile
+
+f = open('src/snapshots.txt')
+lines = f.readlines()
+
+date = lines[0]
+mac = lines[1]
+linux = lines[2]
+win = lines[3]
+
+if 'linux' in sys.platform:
+ me = linux
+elif sys.platform == 'win32':
+ me = win
+elif sys.platform == 'darwin':
+ me = mac
+else:
+ raise Exception("no snapshot for the platform: " + sys.platform)
+
+platform, hash = me.strip().split(' ')
+
+tarball = 'cargo-nightly-' + platform + '.tar.gz'
+url = 'http://static.rust-lang.org/cargo-dist/' + date.strip() + '/' + tarball
+dl_path = "target/dl/" + tarball
+dst = "target/snapshot"
+
+if not os.path.isdir('target/dl'):
+ os.makedirs('target/dl')
+
+ret = subprocess.call(["curl", "-o", dl_path, url])
+if ret != 0:
+ raise Exception("failed to fetch url")
+h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest()
+if h != hash:
+ raise Exception("failed to verify the checksum of the snapshot")
+
+tar = tarfile.open(dl_path)
+for p in tar.getnames():
+ name = p.replace("cargo-nightly/", "", 1)
+ fp = os.path.join(dst, name)
+ print("extracting " + p)
+ tar.extract(p, dst)
+tar.close()
--- /dev/null
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "install: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "install: WARNING: $1"
+}
+
+err() {
+ echo "install: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "install: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "install: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+absolutify() {
+ FILE_PATH="${1}"
+ FILE_PATH_DIRNAME="$(dirname ${FILE_PATH})"
+ FILE_PATH_BASENAME="$(basename ${FILE_PATH})"
+ FILE_ABS_PATH="$(cd ${FILE_PATH_DIRNAME} && pwd)"
+ FILE_PATH="${FILE_ABS_PATH}/${FILE_PATH_BASENAME}"
+ # This is the return value
+ ABSOLUTIFIED="${FILE_PATH}"
+}
+
+msg "looking for install programs"
+need_cmd mkdir
+need_cmd printf
+need_cmd cut
+need_cmd grep
+need_cmd uname
+need_cmd tr
+need_cmd sed
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
+# This logic is duplicated from configure in order to get the correct libdir
+# for Windows installs.
+CFG_OSTYPE=$(uname -s)
+
+case $CFG_OSTYPE in
+
+ MINGW32*)
+ CFG_OSTYPE=pc-mingw32
+ ;;
+
+ MINGW64*)
+ # msys2, MSYSTEM=MINGW64
+ CFG_OSTYPE=w64-mingw32
+ ;;
+
+# Thad's Cygwin identifers below
+
+# Vista 32 bit
+ CYGWIN_NT-6.0)
+ CFG_OSTYPE=pc-mingw32
+ ;;
+
+# Vista 64 bit
+ CYGWIN_NT-6.0-WOW64)
+ CFG_OSTYPE=w64-mingw32
+ ;;
+
+# Win 7 32 bit
+ CYGWIN_NT-6.1)
+ CFG_OSTYPE=pc-mingw32
+ ;;
+
+# Win 7 64 bit
+ CYGWIN_NT-6.1-WOW64)
+ CFG_OSTYPE=w64-mingw32
+ ;;
+esac
+
+OPTIONS=""
+BOOL_OPTIONS=""
+VAL_OPTIONS=""
+
+CFG_LIBDIR_RELATIVE=lib
+
+flag uninstall "only uninstall from the installation prefix"
+valopt destdir "" "set installation root"
+opt verify 1 "verify that the installed binaries run correctly"
+valopt prefix "/usr/local" "set installation prefix"
+# NB This isn't quite the same definition as in `configure`.
+# just using 'lib' instead of CFG_LIBDIR_RELATIVE
+valopt libdir "${CFG_DESTDIR}${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
+valopt mandir "${CFG_DESTDIR}${CFG_PREFIX}/share/man" "install man pages in PATH"
+
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+# OK, let's get installing ...
+
+# Sanity check: can we run the binaries?
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ # Don't do this if uninstalling. Failure here won't help in any way.
+ if [ -z "${CFG_UNINSTALL}" ]
+ then
+ msg "verifying platform can run binaries"
+ "${CFG_SRC_DIR}/bin/cargo" -h > /dev/null
+ if [ $? -ne 0 ]
+ then
+ err "can't execute rustc binary on this platform"
+ fi
+ fi
+fi
+
+# Sanity check: can we can write to the destination?
+msg "verifying destination is writable"
+umask 022 && mkdir -p "${CFG_LIBDIR}"
+need_ok "can't write to destination. consider \`sudo\`."
+touch "${CFG_LIBDIR}/rust-install-probe" > /dev/null
+if [ $? -ne 0 ]
+then
+ err "can't write to destination. consider \`sudo\`."
+fi
+rm -f "${CFG_LIBDIR}/rust-install-probe"
+need_ok "failed to remove install probe"
+
+# Sanity check: don't install to the directory containing the installer.
+# That would surely cause chaos.
+msg "verifying destination is not the same as source"
+INSTALLER_DIR="$(cd $(dirname $0) && pwd)"
+PREFIX_DIR="$(cd ${CFG_PREFIX} && pwd)"
+if [ "${INSTALLER_DIR}" = "${PREFIX_DIR}" ]
+then
+ err "can't install to same directory as installer"
+fi
+
+# Using an absolute path to libdir in a few places so that the status
+# messages are consistently using absolute paths.
+absolutify "${CFG_LIBDIR}"
+ABS_LIBDIR="${ABSOLUTIFIED}"
+
+# The file name of the manifest we're going to create during install
+INSTALLED_MANIFEST="${ABS_LIBDIR}/cargo/manifest"
+
+# First, uninstall from the installation prefix.
+# Errors are warnings - try to rm everything in the manifest even if some fail.
+if [ -f "${INSTALLED_MANIFEST}" ]
+then
+ # Iterate through installed manifest and remove files
+ while read p; do
+ # The installed manifest contains absolute paths
+ msg "removing $p"
+ if [ -f "$p" ]
+ then
+ rm -f "$p"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove $p"
+ fi
+ else
+ warn "supposedly installed file $p does not exist!"
+ fi
+ done < "${INSTALLED_MANIFEST}"
+
+ # If we fail to remove cargo below, then the installed manifest will
+ # still be full; the installed manifest needs to be empty before install.
+ msg "removing ${INSTALLED_MANIFEST}"
+ rm -f "${INSTALLED_MANIFEST}"
+ # For the above reason, this is a hard error
+ need_ok "failed to remove installed manifest"
+
+ # Remove 'rustlib' directory
+ msg "removing ${ABS_LIBDIR}/cargo"
+ rm -Rf "${ABS_LIBDIR}/cargo"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove cargo"
+ fi
+else
+ # There's no manifest. If we were asked to uninstall, then that's a problem.
+ if [ -n "${CFG_UNINSTALL}" ]
+ then
+ err "unable to find installation manifest at ${CFG_LIBDIR}/cargo"
+ fi
+fi
+
+# If we're only uninstalling then exit
+if [ -n "${CFG_UNINSTALL}" ]
+then
+ echo
+ echo " Cargo is uninstalled."
+ echo
+ exit 0
+fi
+
+# Create the installed manifest, which we will fill in with absolute file paths
+mkdir -p "${CFG_LIBDIR}/cargo"
+need_ok "failed to create cargo"
+touch "${INSTALLED_MANIFEST}"
+need_ok "failed to create installed manifest"
+
+# Now install, iterate through the new manifest and copy files
+while read p; do
+
+ # Decide the destination of the file
+ FILE_INSTALL_PATH="${CFG_DESTDIR}${CFG_PREFIX}/$p"
+
+ if echo "$p" | grep "^lib/" > /dev/null
+ then
+ pp=`echo $p | sed 's/^lib\///'`
+ FILE_INSTALL_PATH="${CFG_LIBDIR}/$pp"
+ fi
+
+ if echo "$p" | grep "^share/man/" > /dev/null
+ then
+ pp=`echo $p | sed 's/^share\/man\///'`
+ FILE_INSTALL_PATH="${CFG_MANDIR}/$pp"
+ fi
+
+ # Make sure there's a directory for it
+ umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})"
+ need_ok "directory creation failed"
+
+ # Make the path absolute so we can uninstall it later without
+ # starting from the installation cwd
+ absolutify "${FILE_INSTALL_PATH}"
+ FILE_INSTALL_PATH="${ABSOLUTIFIED}"
+
+ # Install the file
+ msg "${FILE_INSTALL_PATH}"
+ if echo "$p" | grep "^bin/\\|/cargo-" > /dev/null
+ then
+ install -m755 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
+ else
+ install -m644 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
+ fi
+ need_ok "file creation failed"
+
+ # Update the manifest
+ echo "${FILE_INSTALL_PATH}" >> "${INSTALLED_MANIFEST}"
+ need_ok "failed to update manifest"
+
+# The manifest lists all files to install
+done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/cargo/manifest.in"
+
+# Sanity check: can we run the installed binaries?
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ msg "verifying installed binaries are executable"
+ "${CFG_DESTDIR}${CFG_PREFIX}/bin/cargo" -h > /dev/null
+ if [ $? -ne 0 ]
+ then
+ ERR="can't execute installed rustc binary. "
+ ERR="${ERR}installation may be broken. "
+ ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
+ ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
+ err "${ERR}"
+ fi
+fi
+
+echo
+echo " Cargo is ready to roll."
+echo
+
+
--- /dev/null
+# When updating snapshots, run this file and pipe it into `src/snapshots.txt`
+import os
+import subprocess
+import sys
+import hashlib
+
+date = sys.argv[1]
+
+print(date)
+
+if not os.path.isdir('target/dl'):
+ os.makedirs('target/dl')
+
+snaps = ['mac', 'linux', 'win']
+for snap in snaps:
+ tarball = 'cargo-nightly-' + snap + '.tar.gz'
+ url = 'http://static.rust-lang.org/cargo-dist/' + date + '/' + tarball
+ dl_path = "target/dl/" + tarball
+ ret = subprocess.call(["curl", "-s", "-o", dl_path, url])
+ if ret != 0:
+ raise Exception("failed to fetch url")
+ h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest()
+ print(' ' + snap + ' ' + h)
+++ /dev/null
-#!/bin/sh
-# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-msg() {
- echo "install: $1"
-}
-
-step_msg() {
- msg
- msg "$1"
- msg
-}
-
-warn() {
- echo "install: WARNING: $1"
-}
-
-err() {
- echo "install: error: $1"
- exit 1
-}
-
-need_ok() {
- if [ $? -ne 0 ]
- then
- err "$1"
- fi
-}
-
-need_cmd() {
- if command -v $1 >/dev/null 2>&1
- then msg "found $1"
- else err "need $1"
- fi
-}
-
-putvar() {
- local T
- eval T=\$$1
- eval TLEN=\${#$1}
- if [ $TLEN -gt 35 ]
- then
- printf "install: %-20s := %.35s ...\n" $1 "$T"
- else
- printf "install: %-20s := %s %s\n" $1 "$T" "$2"
- fi
-}
-
-valopt() {
- VAL_OPTIONS="$VAL_OPTIONS $1"
-
- local OP=$1
- local DEFAULT=$2
- shift
- shift
- local DOC="$*"
- if [ $HELP -eq 0 ]
- then
- local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
- local V="CFG_${UOP}"
- eval $V="$DEFAULT"
- for arg in $CFG_ARGS
- do
- if echo "$arg" | grep -q -- "--$OP="
- then
- val=$(echo "$arg" | cut -f2 -d=)
- eval $V=$val
- fi
- done
- putvar $V
- else
- if [ -z "$DEFAULT" ]
- then
- DEFAULT="<none>"
- fi
- OP="${OP}=[${DEFAULT}]"
- printf " --%-30s %s\n" "$OP" "$DOC"
- fi
-}
-
-opt() {
- BOOL_OPTIONS="$BOOL_OPTIONS $1"
-
- local OP=$1
- local DEFAULT=$2
- shift
- shift
- local DOC="$*"
- local FLAG=""
-
- if [ $DEFAULT -eq 0 ]
- then
- FLAG="enable"
- else
- FLAG="disable"
- DOC="don't $DOC"
- fi
-
- if [ $HELP -eq 0 ]
- then
- for arg in $CFG_ARGS
- do
- if [ "$arg" = "--${FLAG}-${OP}" ]
- then
- OP=$(echo $OP | tr 'a-z-' 'A-Z_')
- FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
- local V="CFG_${FLAG}_${OP}"
- eval $V=1
- putvar $V
- fi
- done
- else
- if [ ! -z "$META" ]
- then
- OP="$OP=<$META>"
- fi
- printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
- fi
-}
-
-flag() {
- BOOL_OPTIONS="$BOOL_OPTIONS $1"
-
- local OP=$1
- shift
- local DOC="$*"
-
- if [ $HELP -eq 0 ]
- then
- for arg in $CFG_ARGS
- do
- if [ "$arg" = "--${OP}" ]
- then
- OP=$(echo $OP | tr 'a-z-' 'A-Z_')
- local V="CFG_${OP}"
- eval $V=1
- putvar $V
- fi
- done
- else
- if [ ! -z "$META" ]
- then
- OP="$OP=<$META>"
- fi
- printf " --%-30s %s\n" "$OP" "$DOC"
- fi
-}
-
-validate_opt () {
- for arg in $CFG_ARGS
- do
- isArgValid=0
- for option in $BOOL_OPTIONS
- do
- if test --disable-$option = $arg
- then
- isArgValid=1
- fi
- if test --enable-$option = $arg
- then
- isArgValid=1
- fi
- if test --$option = $arg
- then
- isArgValid=1
- fi
- done
- for option in $VAL_OPTIONS
- do
- if echo "$arg" | grep -q -- "--$option="
- then
- isArgValid=1
- fi
- done
- if [ "$arg" = "--help" ]
- then
- echo
- echo "No more help available for Configure options,"
- echo "check the Wiki or join our IRC channel"
- break
- else
- if test $isArgValid -eq 0
- then
- err "Option '$arg' is not recognized"
- fi
- fi
- done
-}
-
-absolutify() {
- FILE_PATH="${1}"
- FILE_PATH_DIRNAME="$(dirname ${FILE_PATH})"
- FILE_PATH_BASENAME="$(basename ${FILE_PATH})"
- FILE_ABS_PATH="$(cd ${FILE_PATH_DIRNAME} && pwd)"
- FILE_PATH="${FILE_ABS_PATH}/${FILE_PATH_BASENAME}"
- # This is the return value
- ABSOLUTIFIED="${FILE_PATH}"
-}
-
-msg "looking for install programs"
-need_cmd mkdir
-need_cmd printf
-need_cmd cut
-need_cmd grep
-need_cmd uname
-need_cmd tr
-need_cmd sed
-
-CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
-CFG_SELF="$0"
-CFG_ARGS="$@"
-
-HELP=0
-if [ "$1" = "--help" ]
-then
- HELP=1
- shift
- echo
- echo "Usage: $CFG_SELF [options]"
- echo
- echo "Options:"
- echo
-else
- step_msg "processing $CFG_SELF args"
-fi
-
-# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
-# This logic is duplicated from configure in order to get the correct libdir
-# for Windows installs.
-CFG_OSTYPE=$(uname -s)
-
-case $CFG_OSTYPE in
-
- MINGW32*)
- CFG_OSTYPE=pc-mingw32
- ;;
-
- MINGW64*)
- # msys2, MSYSTEM=MINGW64
- CFG_OSTYPE=w64-mingw32
- ;;
-
-# Thad's Cygwin identifers below
-
-# Vista 32 bit
- CYGWIN_NT-6.0)
- CFG_OSTYPE=pc-mingw32
- ;;
-
-# Vista 64 bit
- CYGWIN_NT-6.0-WOW64)
- CFG_OSTYPE=w64-mingw32
- ;;
-
-# Win 7 32 bit
- CYGWIN_NT-6.1)
- CFG_OSTYPE=pc-mingw32
- ;;
-
-# Win 7 64 bit
- CYGWIN_NT-6.1-WOW64)
- CFG_OSTYPE=w64-mingw32
- ;;
-esac
-
-OPTIONS=""
-BOOL_OPTIONS=""
-VAL_OPTIONS=""
-
-CFG_LIBDIR_RELATIVE=lib
-
-flag uninstall "only uninstall from the installation prefix"
-valopt destdir "" "set installation root"
-opt verify 1 "verify that the installed binaries run correctly"
-valopt prefix "/usr/local" "set installation prefix"
-# NB This isn't quite the same definition as in `configure`.
-# just using 'lib' instead of CFG_LIBDIR_RELATIVE
-valopt libdir "${CFG_DESTDIR}${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
-valopt mandir "${CFG_DESTDIR}${CFG_PREFIX}/share/man" "install man pages in PATH"
-
-
-if [ $HELP -eq 1 ]
-then
- echo
- exit 0
-fi
-
-step_msg "validating $CFG_SELF args"
-validate_opt
-
-# OK, let's get installing ...
-
-# Sanity check: can we run the binaries?
-if [ -z "${CFG_DISABLE_VERIFY}" ]
-then
- # Don't do this if uninstalling. Failure here won't help in any way.
- if [ -z "${CFG_UNINSTALL}" ]
- then
- msg "verifying platform can run binaries"
- "${CFG_SRC_DIR}/bin/cargo" -h > /dev/null
- if [ $? -ne 0 ]
- then
- err "can't execute rustc binary on this platform"
- fi
- fi
-fi
-
-# Sanity check: can we can write to the destination?
-msg "verifying destination is writable"
-umask 022 && mkdir -p "${CFG_LIBDIR}"
-need_ok "can't write to destination. consider \`sudo\`."
-touch "${CFG_LIBDIR}/rust-install-probe" > /dev/null
-if [ $? -ne 0 ]
-then
- err "can't write to destination. consider \`sudo\`."
-fi
-rm -f "${CFG_LIBDIR}/rust-install-probe"
-need_ok "failed to remove install probe"
-
-# Sanity check: don't install to the directory containing the installer.
-# That would surely cause chaos.
-msg "verifying destination is not the same as source"
-INSTALLER_DIR="$(cd $(dirname $0) && pwd)"
-PREFIX_DIR="$(cd ${CFG_PREFIX} && pwd)"
-if [ "${INSTALLER_DIR}" = "${PREFIX_DIR}" ]
-then
- err "can't install to same directory as installer"
-fi
-
-# Using an absolute path to libdir in a few places so that the status
-# messages are consistently using absolute paths.
-absolutify "${CFG_LIBDIR}"
-ABS_LIBDIR="${ABSOLUTIFIED}"
-
-# The file name of the manifest we're going to create during install
-INSTALLED_MANIFEST="${ABS_LIBDIR}/cargo/manifest"
-
-# First, uninstall from the installation prefix.
-# Errors are warnings - try to rm everything in the manifest even if some fail.
-if [ -f "${INSTALLED_MANIFEST}" ]
-then
- # Iterate through installed manifest and remove files
- while read p; do
- # The installed manifest contains absolute paths
- msg "removing $p"
- if [ -f "$p" ]
- then
- rm -f "$p"
- if [ $? -ne 0 ]
- then
- warn "failed to remove $p"
- fi
- else
- warn "supposedly installed file $p does not exist!"
- fi
- done < "${INSTALLED_MANIFEST}"
-
- # If we fail to remove cargo below, then the installed manifest will
- # still be full; the installed manifest needs to be empty before install.
- msg "removing ${INSTALLED_MANIFEST}"
- rm -f "${INSTALLED_MANIFEST}"
- # For the above reason, this is a hard error
- need_ok "failed to remove installed manifest"
-
- # Remove 'rustlib' directory
- msg "removing ${ABS_LIBDIR}/cargo"
- rm -Rf "${ABS_LIBDIR}/cargo"
- if [ $? -ne 0 ]
- then
- warn "failed to remove cargo"
- fi
-else
- # There's no manifest. If we were asked to uninstall, then that's a problem.
- if [ -n "${CFG_UNINSTALL}" ]
- then
- err "unable to find installation manifest at ${CFG_LIBDIR}/cargo"
- fi
-fi
-
-# If we're only uninstalling then exit
-if [ -n "${CFG_UNINSTALL}" ]
-then
- echo
- echo " Cargo is uninstalled."
- echo
- exit 0
-fi
-
-# Create the installed manifest, which we will fill in with absolute file paths
-mkdir -p "${CFG_LIBDIR}/cargo"
-need_ok "failed to create cargo"
-touch "${INSTALLED_MANIFEST}"
-need_ok "failed to create installed manifest"
-
-# Now install, iterate through the new manifest and copy files
-while read p; do
-
- # Decide the destination of the file
- FILE_INSTALL_PATH="${CFG_DESTDIR}${CFG_PREFIX}/$p"
-
- if echo "$p" | grep "^lib/" > /dev/null
- then
- pp=`echo $p | sed 's/^lib\///'`
- FILE_INSTALL_PATH="${CFG_LIBDIR}/$pp"
- fi
-
- if echo "$p" | grep "^share/man/" > /dev/null
- then
- pp=`echo $p | sed 's/^share\/man\///'`
- FILE_INSTALL_PATH="${CFG_MANDIR}/$pp"
- fi
-
- # Make sure there's a directory for it
- umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})"
- need_ok "directory creation failed"
-
- # Make the path absolute so we can uninstall it later without
- # starting from the installation cwd
- absolutify "${FILE_INSTALL_PATH}"
- FILE_INSTALL_PATH="${ABSOLUTIFIED}"
-
- # Install the file
- msg "${FILE_INSTALL_PATH}"
- if echo "$p" | grep "^bin/\\|/cargo-" > /dev/null
- then
- install -m755 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
- else
- install -m644 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
- fi
- need_ok "file creation failed"
-
- # Update the manifest
- echo "${FILE_INSTALL_PATH}" >> "${INSTALLED_MANIFEST}"
- need_ok "failed to update manifest"
-
-# The manifest lists all files to install
-done < "${CFG_SRC_DIR}/${CFG_LIBDIR_RELATIVE}/cargo/manifest.in"
-
-# Sanity check: can we run the installed binaries?
-if [ -z "${CFG_DISABLE_VERIFY}" ]
-then
- msg "verifying installed binaries are executable"
- "${CFG_DESTDIR}${CFG_PREFIX}/bin/cargo" -h > /dev/null
- if [ $? -ne 0 ]
- then
- ERR="can't execute installed rustc binary. "
- ERR="${ERR}installation may be broken. "
- ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
- ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
- err "${ERR}"
- fi
-fi
-
-echo
-echo " Cargo is ready to roll."
-echo
-
-
--- /dev/null
+2014-07-26
+ mac 9a78815c7fcdb1cdabc93eb120f80444f209d968
+ linux b38e7c45292d2cc6a1932fa9a1f349f9b92c0c1d
+ win 4e955f8b80684ea6c9ca2dd6e2c235ce2d9cf21f
// Path to cargo executables
pub fn cargo_dir() -> Path {
os::getenv("CARGO_BIN_PATH").map(Path::new)
- .or_else(|| os::self_exe_path().map(|p| p.dir_path()))
+ .or_else(|| os::self_exe_path())
.unwrap_or_else(|| {
fail!("CARGO_BIN_PATH wasn't set. Cannot continue running test")
})
-use std::io::fs;
+use std::io::{fs, TempDir};
use std::os;
use std::path;
use std::str;
use support::{ResultTest, project, execs, main_file, basic_bin_manifest};
-use support::{COMPILING, RUNNING, cargo_dir};
+use support::{COMPILING, RUNNING, cargo_dir, ProjectBuilder};
use hamcrest::{assert_that, existing_file};
use cargo;
use cargo::util::{process, realpath};
})
test!(cargo_compile_without_manifest {
- let p = project("foo");
+ let tmpdir = TempDir::new("cargo").unwrap();
+ let p = ProjectBuilder::new("foo", tmpdir.path().clone());
assert_that(p.cargo_process("cargo-build"),
execs()